﻿using System;

using Fuse8.DomainFramework.Common;
using Fuse8.DomainFramework.Common.Locator;
using Fuse8.DomainFramework.BusinessService;

using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Domain.Commands;
using Fuse8.ContentManagementFramework.Domain.Commands.CommandParameters;

namespace Fuse8.ContentManagementFramework.BizFacade.Services
{
    public class CmsMimeTypeService : BaseBusinessService<CmsMimeType, int>
    {
        public CmsMimeType GetByContentType(string contentType)
        {
            Guard.ArgumentNotEmpty(contentType, "contentType");

            var command = DependencyServiceLocator.Current.GetInstance<CmsMimeTypeGetForContentTypeCommand>();

            command.ConfigureCommand(
                            new CmsMimeTypeGetForContentTypeCommandParameter
                            {
                                ContentType = contentType
                            });

            return FindOne(command);
        }
    }
}
